package cn.cque.controller;

import cn.cque.entity.Product;
import cn.cque.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: XWC
 * @ClassName: IndexController
 * @Date: 2020/10/4
 * @Time: 18:34
 * @Description:
 */
@Controller
public class IndexController {

    @Autowired
    ProductService productService;

    @RequestMapping("/index")
    public ModelAndView index(){
        ModelAndView mv=new ModelAndView();
        List<Product> hotList= productService.findHot();
        List<Product> newList= productService.findNew();
        mv.addObject("hotList",hotList);
        mv.addObject("newList",newList);
        mv.setViewName("/jsp/index");
        return mv;
    }
}